package com.p2p.service.operationsManagementService.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.p2p.common.base.RespResult;
import com.p2p.common.base.RespResultCode;
import com.p2p.entity.InviteStrategy;
import com.p2p.mapper.InviteStrategyMapper;
import com.p2p.service.operationsManagementService.InviteStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InviteStrategyServiceImpl implements InviteStrategyService {

    @Autowired
    private InviteStrategyMapper inviteStrategyMapper;

    /**
     * 邀请策略展示
     * @return
     */
    @Override
    public RespResult findInviteStrategyList() {
        List<InviteStrategy> inviteStrategyList = inviteStrategyMapper.findInviteStrategyList();
        if (inviteStrategyList.size() > 0){
            return RespResult.success(inviteStrategyList);
        }
        return RespResult.error(RespResultCode.ERR_PARAM_NOT_LEGAL.getCode(),RespResultCode.ERR_PARAM_NOT_LEGAL.getMessage(),null);
    }

    @Override
    public RespResult updateInviteStrategy(InviteStrategy inviteStrategy) {

        int i = inviteStrategyMapper.updateById(inviteStrategy);
        if (i > 0){
            return RespResult.success();
        }
        return RespResult.error(RespResultCode.ERR_PARAM_NOT_LEGAL.getCode(),RespResultCode.ERR_PARAM_NOT_LEGAL.getMessage(),null);
    }
}
